package com.momoauth.common.security.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class GroupDao {

    @Resource
    JdbcTemplate jdbcTemplate;

    /**
     * 获取用户所在群组名称
     * @param user_id
     * @return
     */
    public String getUserGroupName(Long user_id) {
        String sql = "SELECT groupName FROM `groups` INNER JOIN user_group ON groupId = group_id WHERE user_id = ?";
        return jdbcTemplate.queryForObject(sql, String.class, user_id);
    }
}
